@extends('seller::layout.master')

@section('title', __('seller::category.title'))

@section('content')
<div id="category-app" class="card">
  <div class="card-header">{{ $category->id ? __('seller::category.edit') : __('seller::category.create') }}</div>
  <div class="card-body">

    <form class="needs-validation" novalidate
      action="{{ seller_route($category->id ? 'categories.update' : 'categories.store', $category) }}" method="POST">
      @csrf
      @method($category->id ? 'PUT' : 'POST')

      @if (session('success'))
      <x-seller-alert type="success" msg="{{ session('success') }}" class="mt-4" />
      @endif

      <x-seller-form-input-locale name="descriptions.*.name" title="{{ __('seller::category.name') }}"
        :value="old('descriptions.*.name', $descriptions)" required />
      @if ($errors->first('descriptions.*.name'))
        <div class="invalid-feedback d-flex mb-2" style="margin-top: -10px"><div class="wp-200 d-block"></div>{{ $errors->first('descriptions.*.name') }}</div>
      @endif

      <x-seller-form-input-locale name="descriptions.*.content" title="{{ __('seller::category.content') }}"
        :value="$descriptions" required />
      @if ($errors->first('descriptions.*.content'))
        <div class="invalid-feedback d-flex mb-2" style="margin-top: -10px"><div class="wp-200 d-block"></div>{{ $errors->first('descriptions.*.content') }}</div>
      @endif

      <x-seller-form-input name="position" required title="{{ __('common.sort_order') }}"
        :value="old('position', $category->position ?? 0)" :error="$errors->first('position')" />

      <x-seller-form-switch title="{{ __('common.status') }}" name="active"
        :value="old('active', $category->active ?? 1)" />

      <x-seller::form.row>
        <button type="submit" class="btn btn-primary mt-3">{{ __('common.save') }}</button>
      </x-seller::form.row>
    </form>

  </div>
</div>
@endsection